<?php
namespace Unicom\Controller;
use Think\Controller;

class MemberController extends Controller {
	public function login() {
		layout(false);
		if (IS_GET) {

			$this->display();
		} else {
			$username = I('param.username', '', 'string');
			$password = I('param.password', '', 'string');
			$user = M('cp.member', 'cp_')->where(array('username' => $username))->find();
			if ($user) {
				if ($user['password'] === md5($password)) {
					//$this->redirect('index/index');
					session('user_auth', $user['username']);

					$this->success('登录成功', '', true); //登录成功

				} else {
					$this->error('密码错误', '', true);
				}
			} else {
				$this->error('用户不存在', '', true);
			}
		}

	}

	public function logout() {
		session('user_auth', null);
		$this->redirect('member/login');
	}

}